package com.atguigu.xuexiplus.mapper;

import com.atguigu.xuexiplus.entity.ChatMessageEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ChatMessageMapper extends BaseMapper<ChatMessageEntity> {

    @Select("SELECT * FROM chat_message WHERE ((from_user_id = #{a} AND to_user_id = #{b}) OR (from_user_id = #{b} AND to_user_id = #{a})) ORDER BY created_at ASC LIMIT #{limit} OFFSET #{offset}")
    List<ChatMessageEntity> listHistory(@Param("a") Long a, @Param("b") Long b, @Param("offset") int offset, @Param("limit") int limit);
}


